package artid.com.arttogo.bean;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;

public class NewsContent extends AppItem implements Serializable {
	String title;
	String source;
	String create_time;
	String category_name;
	String content;
	String author;
	String view;
	String weburl;
	int is_commend;
	ArrayList<String> imgurl;
	ArrayList<OtherInfo> otherinfoList;
	String shareurl;
	String infotitle;
	int is_collection;//是否被收藏
	@Override
	public void parse(JSONObject obj) {
		if (null == obj) {
			return;
		}
		is_commend = obj.optInt("is_commend");
		is_collection = obj.optInt("is_collection");
		title = obj.optString("title");
		source = obj.optString("source");
		create_time = obj.optString("create_time");
		content = obj.optString("content");
		category_name = obj.optString("category_name");
		view = obj.optString("view");
		author = obj.optString("author");
		weburl = obj.optString("weburl");
		shareurl = obj.optString("shareurl");
		infotitle = obj.optString("infotitle");
		
		imgurl = new ArrayList<String>();
		
		JSONArray imgArr = obj.optJSONArray("imgurl");
		if (imgArr != null) {
			for (int i = 0; i < imgArr.length(); i++) {
				imgurl.add(imgArr.optString(i));
			}
		}

		JSONArray otherinfo = obj.optJSONArray("otherinfo");
		otherinfoList = new ArrayList<OtherInfo>();
		if (otherinfo != null) {

			for (int i = 0; i < otherinfo.length(); i++) {
				JSONObject item = otherinfo.optJSONObject(i);
				OtherInfo info = new OtherInfo();
				info.setCatname(item.optString("catname"));
				info.setCreate_time(item.optString("create_time"));
				info.setId(item.optString("id"));
				JSONArray imgs = item.optJSONArray("imgUrl");
				info.imgUrl = new ArrayList<String>();
				if (imgs != null) {
					for (int j = 0; j < imgs.length(); j++) {
						info.imgUrl.add(imgs.optString(j));
					}
				}

				info.setSource(item.optString("source"));
				info.setTitle(item.optString("title"));
				info.setCreate_time(item.optString("create_time"));
				info.setTop(item.optString("top"));
				otherinfoList.add(info);
			}
		}

	}

	

	public String getInfotitle() {
		return infotitle;
	}



	public void setInfotitle(String infotitle) {
		this.infotitle = infotitle;
	}



	public String getShareurl() {
		return shareurl;
	}



	public void setShareurl(String shareurl) {
		this.shareurl = shareurl;
	}


	public int getIs_commend() {
		return is_commend;
	}

	public void setIs_commend(int is_commend) {
		this.is_commend = is_commend;
	}

	public int getIs_collection() {
		return is_collection;
	}

	public void setIs_collection(int is_collection) {
		this.is_collection = is_collection;
	}

	public String getWeburl() {
		return weburl;
	}

	public void setWeburl(String weburl) {
		this.weburl = weburl;
	}



	public ArrayList<String> getImgurl() {
		return imgurl;
	}

	public void setImgurl(ArrayList<String> imgurl) {
		this.imgurl = imgurl;
	}

	public ArrayList<OtherInfo> getOtherinfoList() {
		return otherinfoList;
	}

	public void setOtherinfoList(ArrayList<OtherInfo> otherinfoList) {
		this.otherinfoList = otherinfoList;
	}

	public class OtherInfo {
		String source;
		ArrayList<String> imgUrl;
		String id;
		String catname;
		String title;
		String create_time;
		String top;

		public ArrayList<String> getImgUrl() {
			return imgUrl;
		}

		public void setImgUrl(ArrayList<String> imgUrl) {
			this.imgUrl = imgUrl;
		}

		public String getSource() {
			return source;
		}

		public void setSource(String source) {
			this.source = source;
		}

		public String getId() {
			return id;
		}

		public void setId(String id) {
			this.id = id;
		}

		public String getCatname() {
			return catname;
		}

		public void setCatname(String catname) {
			this.catname = catname;
		}

		public String getTitle() {
			return title;
		}

		public void setTitle(String title) {
			this.title = title;
		}

		public String getCreate_time() {
			return create_time;
		}

		public void setCreate_time(String create_time) {
			this.create_time = create_time;
		}

		public String getTop() {
			return top;
		}

		public void setTop(String top) {
			this.top = top;
		}

	}

	public String getCategory_name() {
		return category_name;
	}

	public void setCategory_name(String category_name) {
		this.category_name = category_name;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getView() {
		return view;
	}

	public void setView(String view) {
		this.view = view;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public String getCreate_time() {
		return create_time;
	}

	public void setCreate_time(String create_time) {
		this.create_time = create_time;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

}
